export const FormatDate = (day = new Date(), format = 'ss', split = '-') => {
  const Y = day.getFullYear();
  const M = (day.getMonth() + 1 + '').padStart(2, '0');
  const D = (day.getDate() + '').padStart(2, '0');
  const h = (day.getHours() + '').padStart(2, '0');
  const m = (day.getMinutes() + '').padStart(2, '0');
  const s = (day.getSeconds() + '').padStart(2, '0');
  switch (format) {
    case 'y':
      return `${Y}`;
    case 'm':
      return `${Y}${split}${M}`;
    case 'd':
      return `${Y}${split}${M}${split}${D}`;
    case 'h':
      return `${Y}${split}${M}${split}${D} ${h}`;
    case 'mm':
      return `${Y}${split}${M}${split}${D} ${h}:${m}`;
    case 'ss':
      return `${Y}${split}${M}${split}${D} ${h}:${m}:${s}`;
    default:
      return `${Y}${split}${M}${split}${D} ${h}:${m}:${s}`;
  }
};

export const SetSystemControlValue = (
  form: { [key: string]: any },
  keys: string[],
  data: { [key: string]: any } = {},
) => {
  keys.forEach((key) => {
    switch (key) {
      case 'Creater':
        form.data[key] = data.Creater;
        break;
      case 'UpdateTime':
      case 'CreateTime':
        form.data[key] = FormatDate();
        break;
      default:
        break;
    }
  });
  return form;
};
